<template>
	<view class="mine-userMsg">
		<view class="box1">
			<view class="box2" @click="goGet">
				<view class="msg1">{{userdata.allprofit || 0}}</view>
				<view class="msg2">{{$t('mine.userMsg.profit')}}</view>
			</view>
			<view class="box2" @click="shebei">
				<view class="msg1">{{userdata.machine || 0}}</view>
				<view class="msg2">{{$t('mine.userMsg.equipment')}}</view>
			</view>
			<view class="box2" @click="goFd">
				<view class="msg1">{{userdata.firedcount || 0}}</view>
				<view class="msg2">{{$t('mine.userMsg.goodFd')}}</view>
			</view>
			<view class="box2" @click="goMoney">
				<view class="msg1">{{userdata.money | farmart}}</view>
				<view class="msg2">{{$t('mine.userMsg.wallet')}}</view>
			</view>
			
			<!-- <view class="msg1"><text @click="goGet">{{sy}}</text><text @click="shebei">{{sheb}}</text><text>{{frend}}</text><text>{{money}}</text></view>
			<view class="msg2"><text @click="goGet">收益</text><text @click="shebei">设备</text><text class="fd">好友</text><text>钱包</text></view> -->
		</view>
	</view>
</template>

<script>
	export default {
		props: ['userdata'],
		data() {
			return {};
		},
		filters: {
			farmart(val) {
				if(val > 10000) {
					return (val/10000).toFixed(2) + '万'
				} else {
					return val || 0
				}
			}
		},
		methods:{
			istoken(callback) {
				if(uni.getStorageSync('token')) {
					callback(true)
				}
			},
			goGet(){
				this.istoken((res) => {
					uni.switchTab({
						url:'../../pages/get/get'
					})
				})
			},
			shebei(){
				this.istoken((res) => {
					uni.navigateTo({
						url:'../../pages/shebei/shebei'
					})
				})
			},
			goFd(){
				this.istoken((res) => {
					uni.navigateTo({
						url:'/pages/myArea/myArea'
					})
				})
			},
			goMoney(){
				this.istoken((res) => {
					uni.navigateTo({
						url:'/pages/WithdrawalRecord/WithdrawalRecord'
					})
				})
			}
		}
	}
</script>

<style>
.box1{
		width: 88%;
		margin: auto;
		display: flex;
		flex-wrap: wrap;
		position: relative;
	}
	.box1>image{
		width: 160rpx;
		height: 160rpx;
		border-radius: 50%;
	}
	.box2{
		width: 140rpx;
		text-align: center;
		margin: auto;
	}
	.msg1{
		font-size: 1em;	
	}
	.msg2{
		display: flex;
		justify-content: space-evenly;
		font-size: 24rpx;
		font-weight: 400;
		color: #7E8187;
	}
	.fd{
		position: relative;
		left: -20rpx;
	}
</style>
